import url from '@/tool/index.js'
//预约订单
export const subscribeOrder = (coachid,yuyuedate='',yuyuetime='') => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/yuyue/yuyueHtml',
			data: {
				coachid: coachid,
				yuyuedate:yuyuedate,
				yuyuetime:yuyuetime,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

export const testOrder = (coachid,yuyuedate='',yuyuetime='') => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/practice/yuyueHtml',
			data: {
				coachid: coachid,
				yuyuedate:yuyuedate,
				yuyuetime:yuyuetime,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

export const selectCoupon = (money,subjectsid) => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/yuyue/choosecoupon',
			data: {
				money: money,
				subjectsid:subjectsid,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

export const testSelectCoupon = (money,subjectsid) => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/practice/choosecoupon',
			data: {
				money: money,
				subjectsid:subjectsid,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

export const addOrder = (info) => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/yuyue/addYuyueOrder',
			data: {
				yuyuedate:info.yuyuedate,
				yuyuetime:info.yuyuetime,
				subjectsid:info.subjectsid,
				coachid:info.coachid,
				isothorschool:info.isothorschool,
				tjcoachid:info.tjcoachid,
				drivingschool:info.drivingschool,
				yuyuenumber:info.yuyuenumber,
				price:info.price,
				realname:info.realname,
				phone:info.phone,
				integral:info.integral,
				usercouponid:info.usercouponid,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

export const testAddOrder = (info) => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/practice/addPracticeOrder',
			data: {
				yuyuedate:info.yuyuedate,
				yuyuetime:info.yuyuetime,
				subjectsid:info.subjectsid,
				coachid:info.coachid,
				yuyueclasshour:info.yuyueclasshour,
				price:info.price,
				realname:info.realname,
				phone:info.phone,
				integral:info.integral,
				usercouponid:info.usercouponid,
				starthour:info.starthour,
				endhour:info.endhour,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

export const balancePay = (ordernumber) => { //余额支付
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/yuyue/balancepay',
			data: {
				ordernumber: ordernumber,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

export const payOrder = (ordernumber) => { //订单支付显示界面
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/yuyue/payOrder',
			data: {
				ordernumber: ordernumber,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

export const testBalancePay = (ordernumber) => { //余额支付
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/practice/balancepay',
			data: {
				ordernumber: ordernumber,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

export const testPayOrder = (ordernumber) => { //订单支付显示界面
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/practice/payOrder',
			data: {
				ordernumber: ordernumber,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

export const zeroOrder = (ordernumber) => { //订单支付显示界面
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/practice/NoMoneyPay',
			data: {
				ordernumber: ordernumber,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

export const kaoshiZeroOrder = (ordernumber) => { //订单支付显示界面
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/yuyue/NoMoneyPay',
			data: {
				ordernumber: ordernumber,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}